<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>通用后台-GAdmin</title>
    <!-- Bootstrap CSS -->
    <link href="__PUBLIC__/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/css/site.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-offset-4 col-md-5">
            <form action="" method="post" role="form" class="form-signin" id="loginForm">
                <div class="form-group">
                    <label for="username">用户名</label>
                    <input type="text" class="form-control" name="username" id="username" placeholder="用户名">
                </div>
                <div class="form-group">
                    <label for="password">密码</label>
                    <input type="password" class="form-control" name="password" id="password" placeholder="密码">
                </div>
                <div class="form-group form-inline">
                    <input type="text" class="form-control" name="verifycode" maxlength="5" placeholder="验证码">
                    &nbsp;&nbsp;
                    <img src="{:U('verify')}"  id="verifyImg" title="点击更换验证码">
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-sm btn-primary btn-block" data-loading-text="Loading...">登录</button>
                    <span id="message" class="message"></span>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
<script type="text/javascript" src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/js/jquery.form.js"></script>
<script language="javascript">
    $(document).ready(function(){
        var verifyURL="{:U(MODULE_NAME.'/Public/verify')}";
        $("#username").focus();
        $("#verifyImg").click(function(){
            var src=verifyURL+"/"+Math.random();
            $(this).attr('src',src);
        })
        $("#loginForm").submit(function(){

            $(this).ajaxSubmit({
                beforeSend:function(){ $("#message").html("<div class='alert alert-info'>登录中...</div>");},
                success: function (data){
                    if(data.status==1){
                        $("#message").html('<div class="alert alert-success">'+data.info+'</div>');
                        setTimeout(function(){  window.location.href = '{:U(MODULE_NAME."/Index/index")}'},1000);
                    }else{
                        $("#message").html("<div class='alert alert-error'><button type='button' class='close' data-dismiss='alert'>&times;</button>"+data.info+"</div>");
                        $("#verifyImg").trigger('click');
                    }
                },
                dataType:"json"
            });
            return false;
        });
    });
</script>
</body>
</html>